Skip to content

Fix overlaps.sql test fail on 32 bit Debian due to gcc bug 323 #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

vitcpp
Copy link
Contributor

@vitcpp vitcpp commented Sep 7, 2023

On some 32 bit platforms, there is a gcc bug that makes floating point calculations and comparisons unstable (see the link below). The problem originates in FPU 80 bits registers where double values are not truncated to 64 bit values. When gcc compiles some code with enabled optimizations, the intermediate results may be kept in the FPU registers without truncation to 64 bit values. Extra bits may produce unstable results when comparing the numbers.

The generic solution is to save the intermediate results in the memory where the values are truncated to 64 bit values. It affects the performance but makes the tests stable on all platforms.

PGSPHERE_FLOAT_STORE macro enables storing of intermediate results for FPxx operations in the memory. It is enabled by default for 32 bit platforms. It can be explicitly enabled or disabled in CFLAGS. To enable it for all code the gcc option -ffloat-store may be used as well.

Link to gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323

On some 32 bit platforms, there is a gcc bug that makes floating point
calculations and comparisons unstable (see the link below). The problem
originates in FPU 80 bits registers where double values are not truncated
to 64 bit values. When gcc compiles some code with enabled optimizations,
the intermediate results may be kept in the FPU registers without truncation
to 64 bit values. Extra bits may produce unstable results when comparing
the numbers.

The generic solution is to save the intermediate results in the memory where
the values are truncated to 64 bit values. It affects the performance but
makes the tests stable on all platforms.

PGSPHERE_FLOAT_STORE macro enables storing of intermediate results for FPxx
operations in the memory. It is enabled by default for 32 bit platforms.
It can be explicitly enabled or disabled in CFLAGS. To enable it for all
code the gcc option -ffloat-store may be used as well.

Link to gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
@vitcpp vitcpp linked an issue Sep 7, 2023 that may be closed by this pull request
Copy link
Contributor

@esabol esabol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@vitcpp vitcpp merged commit fb93eb4 into postgrespro:master Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sellipse/scircle overlaps regression tests
2 participants